package com.iven.xie.encrypt.util;

import org.apache.tomcat.util.codec.binary.Base64;

/**
 * <p>BASE64加密工具类</p>
 *
 * @author iven.xie
 */
public class BASE64EncryptUtil {

    /**
     * base64 解码
     *
     * @param str
     * @return
     */
    public static String decrypt(String str) {
        return decrypt(str.getBytes());
    }

    /**
     * base64 解码
     *
     * @param bytes
     * @return
     */
    public static String decrypt(byte[] bytes) {
        return new String(Base64.decodeBase64(bytes));
    }

    /**
     * base64 编码
     *
     * @param str
     * @return
     */
    public static String encrypt(String str) {
        return encrypt(str.getBytes());
    }

    /**
     * base64 编码
     *
     * @param bytes
     * @return
     */
    public static String encrypt(byte[] bytes) {
        return new String(Base64.encodeBase64(bytes));
    }

}
